def combineList(allList):
    if len(allList) < 2:
        return allList
    resList = combineTwoList([[]], allList[0])
    for i in range(1, len(allList)):
        resList = combineTwoList(resList, allList[i])

    return resList


def combineTwoList(listOne, listTwo):
    resList = []
    for i in range(len(listOne)):
        for k in range(len(listTwo)):
            tmpList = listOne[i][:]
            tmpList.extend(listTwo[k])
            resList.append(tmpList)
    return resList


if __name__ == '__main__':
    allList = [['1', 'A'], ['2'], ['3', 'C'], ['4', 'D', 'E'], ['5']]
    # allList = [['1', 'A'], ['2'], ['3', 'C']]
    print(combineList(allList))
